#include <stdio.h>

/* convert.c
 *
 * this program converts exe/dll file to com file.
 */

void usage( char **argv ) {

  printf( "usage : %s <input binary file> <output binary file>\n", argv[ 0 ] ) ;
  return ;

}


int main( int argc, char **argv ) {

  FILE *fin, *fout ;
  int c ;
  unsigned int i = 0 ;

  if( argc != 3 ) {
    usage( argv ) ;
    return -1 ;
  }

  if( ! ( fin = fopen( argv[ 1 ], "rb" ) ) ) {
    printf( "failed to open input file.\n" ) ;
    return -1 ;
  }

  if( ! ( fout = fopen( argv[ 2 ], "wb" ) ) ) {
    printf( "failed to open output file.\n" ) ;
    fclose( fin ) ;
    return -1 ;
  }

  while( ( c = getc( fin ) ) != EOF ) {
    if( i > 63 ) {
      if( i == 68 )
        putc( 1, fout ) ;
      else
        putc( c, fout ) ;
    }
    i++ ;
  }

  fclose( fin ) ;
  fclose( fout ) ;

  return 0 ;

}
